//引入请求函数
import request from "@/utils/request.ts";
import { requestHttp } from "@/utils/request.ts";

//引入类型约束

/**
 * 订单相关请求api
 */


//创建一条用户订单(包含商品订单)【废弃】
export const reqSaveUserOrder = (userOrderInfo:any) => {
    return requestHttp<any>({
        url:"/reception/user/order",
        method:"post",
        data:userOrderInfo
    })
}

//创建一条商品订单
export const reqSaveProductOrder = (orderInfo:any) => {
    return requestHttp({
        url:"/reception/user/order",
        method:"post",
        data:orderInfo
    })
}

//批量创建商品订单(批量)
export const reqSaveProductOrderBatch = (orderInfoList:any) => {
    return requestHttp({
        url:"/reception/user/order/batch",
        method:"post",
        data:orderInfoList
    })
}

//查询当前用户的某条订单数据
export const reqProductOrderById = (orderId:string) => {
    return requestHttp({
        url:"/reception/user/order",
        method:"get",
        params:{
            orderId:orderId
        }
    })
}

//查询用户多条订单数据(订单id order_id = ?)
export const reqProductOrderByIds = (orderIds:string[]) => {
    return requestHttp({
        url:"/reception/user/order/batch",
        method:"get",
        params:{
            orderIds:orderIds.toString()
        }
    })
}

//查询当前用户相关状态的订单 状态(未支付，已支付，待发货，已发货，运输中，已收货，已评价，已取消，已退货)
export const reqProductOrderListByUserIdAndOrderState = (userId:number, orderState:string) => {
    return requestHttp({
        url:"/reception/user/order/state",
        method:"get",
        params:{
            userId:userId,
            orderState:orderState
        }
    })
}

//查询当前用户的所有订单数据
export const reqUserAllProductList = (userId:number) => {
    return requestHttp({
        url:"/reception/user/order/all",
        method:"get",
        params:{
            userId:userId
        }
    })
}

//修改用户某条订单信息(主要是 订单联系人、联系人号码、联系人地址、备注、订单状态)
export const reqUpdateProductOrder = (orderInfo:any) => {
    return requestHttp({
        url:"/reception/user/order",
        method:"put",
        data:orderInfo
    })
}

//删除用户订单(支持单条、多条删除)
export const reqDeleteProductOrder = (orderIds:string[]) => {
    return requestHttp({
        url:"/reception/user/order/batch",
        method:"delete",
        data:orderIds
    })
}